﻿Imports System.Collections
Imports System.Net.Sockets
Imports System.Net

Public Class LoginServer

    Public Shared client As New TcpClient()
    Public Shared handler As ISCHandler

    Public Shared Sub connectToLogin()
        Try
            client.Connect(IPAddress.Parse(Config.ISCIP), Config.ISCLoginServerPort)
            Dim pc As New ISCPacketCreator(client)
            pc.addInt(&H1)
            pc.addString(Config.ClusterServerName)
            pc.addString(Config.ClusterServerIP)
            pc.send()
        Catch
            log.log(LogType.MSG_ERROR, "Could not connect to LoginServer.")
            Threading.Thread.Sleep(1000)
            End
        End Try
    End Sub

    Public Shared Sub updateCluster()
        Dim pc As New ISCPacketCreator(client)
        pc.addInt(&H2)
        pc.addString(Config.ClusterServerName)
        pc.addString(Config.ClusterServerIP)
        pc.addInt(ISC.channels.Count)
        For i As Integer = 1 To ISC.channels.Count Step i + 1
            pc.addString("Channel " & i)
        Next
        pc.send()
    End Sub

End Class